package dao.impl;

import dao.IOrderDao;
import model.Goods;
import model.Order;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

/**
 * @aythor:侯仪澳
 * @data:2022/7/21
 */
@Repository

public class OrderDao implements IOrderDao {
    @Autowired
    private SqlSession sqlSession;
    String url = "dao.IOrderDao.";

    //查询所有订单
    @Override
    public List<Order> queryAllOrder(Order order) {
        return sqlSession.selectList(url + "queryAllOrder",order);
    }

    //查询一个订单
    @Override
    public Order queryOneOrder(Order order) {
        return sqlSession.selectOne(url + "queryOneOrder",order);
    }

    //查询所有订单分页
    @Override
    public List<Order> orderLimitPage(Map<String, Object> map) {
        return sqlSession.selectList(url + "orderLimitPage",map);
    }

    //修改发货退款状态值
    @Override
    public int updateOrderBatch(List<Order> list) {
        return sqlSession.update(url + "updateOrderBatch",list);
    }

    //修改一个发货退款状态值
    @Override
    public int updateOneOrderBatch(Order order)  {
        return sqlSession.update(url + "updateOneOrderBatch",order);
    }

    @Override
    public int addOneOrder(Order order) {
        return sqlSession.insert(url + "addOneOrder",order);
    }

    @Override
    public int updateOrderStatus(Order order) {
        return sqlSession.insert(url + "updateOrderStatus",order);
    }

    //定时任务
    @Override
    public int jobForOrder() {
        return sqlSession.update(url + "jobForOrder");
    }
}
